#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QStackedWidget>
#include"mysqlite.h"
#include <QSqlTableModel>
#include<QPushButton>
#include <QLineEdit>
#include <QDateEdit>
#include <QTableView>
#include <QCheckBox>
#include <QComboBox>
#include<QVector>
#include<QtCharts>
#include"income_model.h"
#if _MSC_VER >= 1600
    #pragma execution_character_set("utf-8")
#endif

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE
struct stEarn
{
  int month;
  float earn;
};
struct stCost
{
  int month;
  float cost;
};
class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

private:
    Ui::MainWindow *ui;
    //void CreatMenu();
    void CreatNaviBar();
    void creatStackWidget();
    void SwitchPage();
    void checkDB();
    mySqlite *mysql;
    QStackedWidget *stackWidget;
        QAction *homeAction;
        QAction *supplierAction;
        QAction *goodsAction;
        QAction *stockAction;
        QAction *infoAction;
        QAction *userAction;
    //supplierPage
    QWidget* creatSupplierPage();
        QPushButton *addButton;
        QPushButton *deletButton;
        QPushButton *modifyButton;
        QPushButton *searchButton;
        QLineEdit *nameEdit;
        QDateEdit *dateEdit;
        QLineEdit *priceEdit;
        QLineEdit *numEdit;
        QTableView *tableView;
        QSqlTableModel *supplierModel;
        void addSupplier();
        void deleteSupplierData();
        void modifySupplierData();
        void searchSupplierData();
    //outputPage
    QWidget* creatOutputPage();
        QPushButton *outaddBtn;
        QPushButton *outDelBtn;
        QPushButton *outModifyBtn;
        QPushButton *outSearchBtn;
        QLineEdit *outName;
        QDateEdit *outDate;
        QLineEdit *outClient;
        QLineEdit *outPrice;
        QLineEdit *outNum;
        QCheckBox *outFinalPay;
        QTableView *outTable;
        QSqlTableModel *outModel;
        void addOutgoods();
        void deleteOutgoods();
        void modifyOutgoods();
        void searchOutgoods();
    //stockPage
    QWidget* creatStockPage();
        QPushButton *stockAlarmBtn;
        QPushButton *stockRefreshBtn;

        QLineEdit *stockAlarmEdit;
        //QSqlTableModel *stockModel;
        Income_Model *stockModel;
        QTableView *stockTable;
        void modifyStock();
        void refreshStock();



    //earningPage
    QWidget* creatEarning();
        QPushButton* earnSearchBtn;
        QSqlTableModel *earingModel;
        QTableView *earingTable;
         QLineEdit *dateBox;
        void searchEarnDate();
    //charts
    QWidget* creatReport();
    QPushButton* reportBtn;
    QLineEdit *reportEdit;
    int getYear();
    void searchYearBtn();
    void SelectYearData(int year);
    QBarSet *set0;
    QBarSet *set1;
    QVector<stEarn>vcearn;
    QVector<stCost>vccost;
};




#endif // MAINWINDOW_H
